package com.greenline.search.report.entity;

import java.io.Serializable;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * User: liulei
 * Date: 14-2-12
 * Time: 下午5:23
 * To change this template use File | Settings | File Templates.
 */
public class SearchWord implements Serializable, Comparable{
    private String text;
    private Integer frequency;
    private Integer currentWeekRank;
    private Integer lastWeekRank;
    private Integer rankDifference;
    private String[] tokenArray;
    private String[] typeArray;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Integer getFrequency() {
        return frequency;
    }

    public void setFrequency(Integer frequency) {
        this.frequency = frequency;
    }

    public Integer getCurrentWeekRank() {
        return currentWeekRank;
    }

    public void setCurrentWeekRank(Integer currentWeekRank) {
        this.currentWeekRank = currentWeekRank;
    }

    public Integer getLastWeekRank() {
        return lastWeekRank;
    }

    public void setLastWeekRank(Integer lastWeekRank) {
        this.lastWeekRank = lastWeekRank;
    }

    public Integer getRankDifference() {
        return rankDifference;
    }

    public void setRankDifference(Integer rankDifference) {
        this.rankDifference = rankDifference;
    }

    public String[] getTokenArray() {
        return tokenArray;
    }

    public void setTokenArray(String[] tokenArray) {
        this.tokenArray = tokenArray;
    }

    public String[] getTypeArray() {
        return typeArray;
    }

    public void setTypeArray(String[] typeArray) {
        this.typeArray = typeArray;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof SearchWord){
            if(((SearchWord) obj).getText().equals(this.getText())){
                return true;
            } else {
                return false;
            }
        }else {
            return false;
        }
    }

    @Override
    public int compareTo(Object o) {
        SearchWord objWord = (SearchWord) o;
        if(this.getFrequency() > objWord.getFrequency()){
            return -1;
        } else if(this.getFrequency() < objWord.getFrequency()){
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public String toString() {
        return "SearchWord{" +
                "text='" + text + '\'' +
                ", frequency=" + frequency +
                ", currentWeekRank=" + currentWeekRank +
                ", lastWeekRank=" + lastWeekRank +
                ", rankDifference=" + rankDifference +
                ", tokenArray=" + Arrays.toString(tokenArray) +
                ", typeArray=" + Arrays.toString(typeArray) +
                '}';
    }



}
